package com.bbms.dao.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.stereotype.Repository;

import com.bbms.dao.BookCategoryDAO;
import com.bbms.entity.BookCategory;
import com.bbms.entity.Page;
import com.bbms.util.HibernateUtil;

/**
 * @author Administrator
 * BookCategoryDAO实现类
 */
@Repository("BookCategoryDAOImpl")
public class BookCategoryDAOImpl implements BookCategoryDAO {

	public BookCategoryDAOImpl() {
		super();
	}

	/* 保存图书类型
	 * @see com.bbms.dao.BaseDAO#save(java.lang.Object)
	 */
	@Override
	public void save(BookCategory t) {
		HibernateUtil.save(t);
	}

	/* 更新图书类型
	 * @see com.bbms.dao.BaseDAO#update(java.lang.Object)
	 */
	@Override
	public void update(BookCategory t) {
		HibernateUtil.update(t);
	}

	/* 删除图书类型
	 * @see com.bbms.dao.BaseDAO#delete(java.lang.Object)
	 */
	@Override
	public void delete(BookCategory t) {
		HibernateUtil.delete(t);
	}
	
	/* 分页查询(返回分页对象)
	 * @see com.bbms.dao.BaseDAO#getPage(int, int)
	 */
	@Override
	public Page getPage(int currentPage, int pageSize) {
		Page page = new Page();
		DetachedCriteria dc = DetachedCriteria.forClass(BookCategory.class);
		page = HibernateUtil.getPage(dc, currentPage, pageSize);
		
		return page;
	}
	
	/* 简单查询(获得所有记录)
	 * @see com.bbms.dao.BaseDAO#query()
	 */
	@Override
	public List<?> query() {
		DetachedCriteria dc = DetachedCriteria.forClass(BookCategory.class);
		List<?> list = HibernateUtil.query(dc);
		
		return list;
	}
	
}
